package com.hsnn.medstgmini.base.std.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.springframework.format.annotation.DateTimeFormat;

import com.hsnn.medstgmini.base.dict.model.DicArea;
import com.hsnn.medstgmini.base.dict.model.DicHosptype;
import com.hsnn.medstgmini.model.Status;
import com.hsnn.medstgmini.util.DateUtil;
import com.hsnn.medstgmini.util.PinYin;

/**
 * @category 医疗机构库
 * @author CCL
 */
@Entity
@Table(name = "std_hospinfo_log")
public class HospInfoLog implements Serializable {

	private static final long serialVersionUID = 1L;

	@Id
	@Column(name = "log_id")
	private String logId;

	@Column(name = "hosp_id")
	private String hospId;

	@Column(name = "hosp_code")
	private String hospCode;

	@Column(name = "hosp_name")
	private String hospName;

	@Column(name = "hosp_spel_code")
	private String hospSpelCode;

	@Column(name = "hosp_short_name")
	private String hospShortName;

	@Column(name = "hosp_short_spel_code")
	private String hospShortSpelSode;

	@Column(name = "org_code")
	private String orgCode;

	@Column(name = "hosp_classify")
	private Integer hospClassify;

	@Transient
	private String hospClassifyName;

	@Column(name = "hosp_level_id")
	private String hospLevelId;

	@Transient
	private String hospLevelName;

	@Column(name = "hosp_address")
	private String hospAddress;

	@Column(name = "hosp_phone")
	private String hospPhone;

	@Column(name = "status")
	private Integer status;

	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@Column(name = "upd_datetime")
	private Date updDateTime;

	@Transient
	private String updDateTimeStr;

	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@Transient
	private Date startTime;

	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@Transient
	private Date endTime;

	@Column(name = "upd_user")
	private String updUser;

	@Column(name = "history_code")
	private String historyCode;

	@Column(name = "merge_state")
	private Integer mergeState;

	@OneToOne(fetch = FetchType.EAGER, mappedBy = "hospInfoLog", cascade = CascadeType.ALL)
	private HospInfoDetailLog hospInfoDetailLog;

	@Transient
	private String statusName;

	@OneToOne
	@NotFound(action = NotFoundAction.IGNORE)
	@JoinColumn(name = "area_id", referencedColumnName = "area_id")
	private DicArea area;

	@OneToOne
	@NotFound(action = NotFoundAction.IGNORE)
	@JoinColumn(name = "hosp_type_id", referencedColumnName = "hosp_type_id")
	private DicHosptype hosptype;

	public String getHospId() {
		return hospId;
	}

	public void setHospId(String hospId) {
		this.hospId = hospId;
	}

	public String getHospCode() {
		return hospCode;
	}

	public void setHospCode(String hospCode) {
		this.hospCode = hospCode;
	}

	public String getHospName() {
		return hospName;
	}

	public void setHospName(String hospName) {
		if (hospName != null && !"".equals(hospName)) {
			hospSpelCode = PinYin.getPinYin(hospName);
		}
		this.hospName = hospName;
	}

	public String getHospSpelCode() {
		return hospSpelCode;
	}

	public void setHospSpelCode(String hospSpelCode) {
		this.hospSpelCode = hospSpelCode;
	}

	public String getHospShortName() {
		return hospShortName;
	}

	public void setHospShortName(String hospShortName) {
		if (hospShortName != null && !"".equals(hospShortName)) {
			hospShortSpelSode = PinYin.getPinYin(hospShortName);
		}
		this.hospShortName = hospShortName;
	}

	public String getHospShortSpelSode() {
		return hospShortSpelSode;
	}

	public void setHospShortSpelSode(String hospShortSpelSode) {
		this.hospShortSpelSode = hospShortSpelSode;
	}

	public String getOrgCode() {
		return orgCode;
	}

	public void setOrgCode(String orgCode) {
		this.orgCode = orgCode;
	}

	public Integer getHospClassify() {
		return hospClassify;
	}

	public void setHospClassify(Integer hospClassify) {
		this.hospClassify = hospClassify;
	}

	public String getHospLevelId() {
		return hospLevelId;
	}

	public void setHospLevelId(String hospLevelId) {
		this.hospLevelId = hospLevelId;
	}

	public String getHospAddress() {
		return hospAddress;
	}

	public void setHospAddress(String hospAddress) {
		this.hospAddress = hospAddress;
	}

	public String getHospPhone() {
		return hospPhone;
	}

	public void setHospPhone(String hospPhone) {
		this.hospPhone = hospPhone;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public String getUpdUser() {
		return updUser;
	}

	public void setUpdUser(String updUser) {
		this.updUser = updUser;
	}

	public String getHistoryCode() {
		return historyCode;
	}

	public void setHistoryCode(String historyCode) {
		this.historyCode = historyCode;
	}

	public Integer getMergeState() {
		return mergeState;
	}

	public void setMergeState(Integer mergeState) {
		this.mergeState = mergeState;
	}

	public HospInfoDetailLog getHospInfoDetailLog() {
		return hospInfoDetailLog;
	}

	public void setHospInfoDetailLog(HospInfoDetailLog hospInfoDetailLog) {
		this.hospInfoDetailLog = hospInfoDetailLog;
	}

	public String getStatusName() {
		if (status != null) {
			statusName = Status.getName(status);
		}
		return statusName;
	}

	public void setStatusName(String statusName) {
		this.statusName = statusName;
	}

	public DicArea getArea() {
		return area;
	}

	public void setArea(DicArea area) {
		this.area = area;
	}

	public DicHosptype getHosptype() {
		return hosptype;
	}

	public void setHosptype(DicHosptype hosptype) {
		this.hosptype = hosptype;
	}

	public String getHospLevelName() {
		if (hospLevelId != null) {
			hospLevelName = HospLevel.getName(hospLevelId);
		}
		return hospLevelName;
	}

	public void setHospLevelName(String hospLevelName) {
		this.hospLevelName = hospLevelName;
	}

	public String getLogId() {
		return logId;
	}

	public void setLogId(String logId) {
		this.logId = logId;
	}

	public Date getStartTime() {
		return startTime;
	}

	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}

	public Date getEndTime() {
		return endTime;
	}

	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}

	public String getUpdDateTimeStr() {
		if (updDateTime != null) {
			updDateTimeStr = DateUtil.date(updDateTime);
		}
		return updDateTimeStr;
	}

	public void setUpdDateTimeStr(String updDateTimeStr) {
		this.updDateTimeStr = updDateTimeStr;
	}

	public String getHospClassifyName() {
		if (hospClassify != null) {
			hospClassifyName = HospClassify.getName(hospClassify);
		}
		return hospClassifyName;
	}

	public void setHospClassifyName(String hospClassifyName) {
		this.hospClassifyName = hospClassifyName;
	}

	public Date getUpdDateTime() {
		return updDateTime;
	}

	public void setUpdDateTime(Date updDateTime) {
		this.updDateTime = updDateTime;
	}

}